//
//  GuideViewController.m
//  项目一TimeMovie
//
//  Created by apple on 16/4/8.
//  Copyright © 2016年 huangmingyu. All rights reserved.
//

#import "GuideViewController.h"
#import "HomeTabBarController.h"


@interface GuideViewController () <UIScrollViewDelegate> {
    
    UIScrollView *scroll;
    
}

@end

@implementation GuideViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self createUI];
    
}

- (void)createUI {
    
    scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    scroll.pagingEnabled = YES;
    scroll.delegate = self;
    scroll.showsHorizontalScrollIndicator = NO;

    scroll.contentSize = CGSizeMake(5 * kScreenWidth, kScreenHeight);
    for (int i = 0 ; i < 5; i++) {
        
        NSString *imageName = [NSString stringWithFormat:@"guide%d", i+1];
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i * kScreenWidth, 0, kScreenWidth, kScreenHeight)];
        imageView.image = [UIImage imageNamed:imageName];
        
        NSString *processName = [NSString stringWithFormat:@"guideProgress%d@2x",i +1];
        UIImageView *processView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:processName]];
        processView.frame = CGRectMake(kScreenWidth /2 - processView.image.size.width / 2, kScreenHeight - 50, processView.image.size.width, processView.image.size.height);
        [imageView addSubview:processView];
        [scroll addSubview:imageView];
        
        
    }
    [self.view addSubview:scroll];
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
    
    if (scrollView.contentOffset.x == 4 * kScreenWidth) {
        
        
        [UIView transitionWithView:self.view.window duration:0.5 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
            
            HomeTabBarController *root = [[HomeTabBarController alloc] init];
            self.view.window.rootViewController = root;
        } completion:^(BOOL finished) {
            
            NSLog(@"我只能说我是最帅的");
        }];
    }
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
